$(function(){
	var dataCode = getQueryString("code");
	var data = {
		code:dataCode
	}
	$.ajax({
		data:data,
		type:"post",
		dataType:"json",
		contentType:"application/x-www-form-urlencoded",
		xhrFields:{
			withCredentials:true
		},
		crossDomain:true,
		url:host + "/terminal/orderItem/shipping",
		beforeSend:function(){
			$('.information ul').html('<span style="padding-left:15px;">加载中...</span>');
		},
		success:function(data){

			console.log(data)
			if (data.code == 2000) {
				if (data.data.shippingInfo.State == 3) {
					$('.state span').text("已签收")
				}else{
					$('.state span').text("已发货")
				}
				$('.information ul').text('');
				if ( data.data.shippingInfo.Traces.length == 0) {
					$('.information ul').html('<span style="padding-left:15px;">'+data.data.shippingInfo.Reason+'</span>');
				};
				for (var i = 0; i < data.data.shippingInfo.Traces.length; i++) {
					var year = data.data.shippingInfo.Traces[i].AcceptTime.substring(0,4);
					var date = data.data.shippingInfo.Traces[i].AcceptTime.substring(5,10);
					var time = data.data.shippingInfo.Traces[i].AcceptTime.substring(11);
					if (i!= data.data.shippingInfo.Traces.length-1) {
						var _html = '<li><i class="node_icon"></i><span>'
						+ date
						+ '</br>'
						+ year
						+ '</span><span style="width:63%;">'
						+ data.data.shippingInfo.Traces[i].AcceptStation
						+ '</br>周三&nbsp;&nbsp;'
						+ time
						+'</span></li><li class="icon"><span></span></li>'
					}else{
						var _html = '<li><i class="node_icon" id="node_icon"></i><span>'
						+ date
						+ '</br>'
						+ year
						+ '</span><span style="width:63%;"><b>'
						+ data.data.shippingInfo.Traces[i].AcceptStation
						+ '</b></br>周三&nbsp;&nbsp;'
						+ time
						+'</span></li>'
					}
					
					$('.information ul').append(_html);

				};
				

			};
		},
		error:function(){
			alert("交互异常");
		}
	});
	$.ajax({
		data:data,
		type:"post",
		dataType:"json",
		contentType:"application/x-www-form-urlencoded",
		xhrFields:{
			withCredentials:true
		},
		crossDomain:true,
		url:host + "/terminal/orderItem/details",
		success:function(data){
			console.log(data)
			if (data.code == 2000) {
				(data.data.orderItem.shipperName!=null)?$('#shipperName').text(data.data.orderItem.shipperName):$('#shipperName').text("暂无数据");
				(data.data.orderItem.shippingCode!=null)?$('#shippingCode').text(data.data.orderItem.shippingCode):$('#shippingCode').text("暂无数据");
				if(data.data.orderItem.orderShipping!=null){
					$('#address').html(data.data.orderItem.orderShipping.fullName
						+ '&nbsp;&nbsp;'+data.data.orderItem.orderShipping.zip
						+ '&nbsp;&nbsp;'+data.data.orderItem.orderShipping.mobile
						+ '</br>'
						+ data.data.orderItem.orderShipping.province
						+ data.data.orderItem.orderShipping.city
						+ data.data.orderItem.orderShipping.district
						+ data.data.orderItem.orderShipping.address
						);

				}
				else{
					$('#address').text("暂无数据");
				}	


			};
		},
		error:function(){
			alert("交互异常");
		}
	});
})